#include "stdafx.h"
#include "GridExample.h"

void GridExample::loadFile(const String& fileName, FCView *view){
    FCUIXml::loadFile(fileName, view);
    FCGrid *grid = getGrid(L"Grid");
    //获取第二页
    FCTabPage *tabPage = getTabPage(L"TabPage2");
    FCGrid *newGrid = new FCGrid();
    FCPoint point = {50, 50};
    newGrid->setLocation(point);
    FCSize size = {400, 400};
    newGrid->setSize(size);
    tabPage->addView(newGrid);

   for (int i = 0; i < 10; i++)
   {
       newGrid->addColumn(new FCGridColumn(String(L"Column") + FCTran::intToStr(i)));
   }
   newGrid->update();
   for (int i = 0; i < 1000; i++)
   {
       FCGridRow *row = new FCGridRow();
       newGrid->addRow(row);
       row->addCell(0, new FCGridStringCell(L"Cell1"));
       row->addCell(1, new FCGridIntCell(100));
       row->addCell(2, new FCGridDoubleCell(50));
       row->addCell(3, new FCGridBoolCell(true));
       row->addCell(4, new FCGridCheckBoxCell());
       FCGridButtonCell *buttonCell = new FCGridButtonCell();
       row->addCell(5, buttonCell);
       buttonCell->getButton()->setText(L"确定");
       row->addCell(6, new FCGridTextBoxCell());
       row->addCell(7, new FCGridLongCell(100));
       FCGridPasswordCell *pwdCell = new FCGridPasswordCell();
       pwdCell->setText(L"1111");
       row->addCell(8, pwdCell);
       FCGridComboBoxCell *comboBoxCell = new FCGridComboBoxCell();
       row->addCell(9, comboBoxCell);
       comboBoxCell->getComboBox()->addItem(new FCMenuItem(L"选项1"));
       comboBoxCell->getComboBox()->addItem(new FCMenuItem(L"选项2"));
       comboBoxCell->getComboBox()->addItem(new FCMenuItem(L"选项3"));
       comboBoxCell->getComboBox()->setSelectedIndex(0);
   }
   newGrid->update();
}
